package com.pig4cloud.pig.village.house.controller;


import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.village.api.dto.HouseDTO;
import com.pig4cloud.pig.village.api.entity.House;
import com.pig4cloud.pig.village.house.service.IHouseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author jimi.jin
 * @date 2022/3/14
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/house-resource")
@Api(value = "house-resource", tags = "房屋资源管理")
public class HouseController {
	@Resource
	private IHouseService houseService;

	@PostMapping("/add")
	@ApiOperation("增加房屋信息")
	public R add(@RequestBody House house) {
		return R.ok(houseService.save(house));
	}

	@PostMapping("/update")
	@ApiOperation("传入ID更新房屋信息")
	public R update(@RequestBody House house) {
		return R.ok(houseService.updateById(house));
	}

	@PutMapping("/delete")
	@ApiOperation("删除房屋信息")
	public R delete(Long id) {
		return R.ok(houseService.removeById(id));
	}

	@GetMapping("/get")
	@ApiOperation("获得特定ID的房屋信息")
	public R<HouseDTO>get(Long id){return R.ok(houseService.getDtoById(id));}

	@GetMapping("/getSpe")
	@ApiOperation("预留接口")
	public R<List<HouseDTO>> getSpe(){return R.ok(houseService.getHouse());}
}
